<?php
//=======================================
//###################################
// Kayako Web Solutions
//
// Source Copyright 2001-2004 Kayako Infotech Ltd.
// Unauthorized reproduction is not allowed
// License Number: $%LICENSE%$
// $Author: vshoor $ ($Date: 2006/03/06 20:23:49 $)
// $RCSfile: index.php,v $ : $Revision: 1.5 $ 
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//###################################
//=======================================


header("Content-type: text/vnd.wap.wml");

define("SWIFT_AREA", 100);

if (defined("SWIFTCUSTOMPATH"))
{
	chdir(SWIFTCUSTOMPATH);
} else {
	chdir('./../');
}
require_once ("./swift.php");
require_once ("./includes/functions_wap.php");


if ($_REQUEST["_ca"] == "login") {
	$staffid = $staffauth->authenticate($_POST["username"], $_POST["password"]);
	if (!empty($staffid))
	{
		// Authentication successfull, Generate a sessionid for this user
		$session->insertSession(SESSION_WAP, $staffid);

		header("location: index.php?_m=tickets&_a=list");
	} else {

		displayWAPLoginForm($_SWIFT["errorstr"]);
	}
} else if ($_REQUEST["_ca"] == "logout") {
	$session->logoutSession(SESSION_WAP);

	displayWAPLoginForm($_SWIFT["language"]["loggedout"]);
} else {
	if (!$session->start(SESSION_WAP)) {
		// Failed to load session
		displayWAPLoginForm($_SWIFT["errorstr"]);
		exit;
	}

	// User logged in, trigger events
	if (!$events->triggerEvent(EVENT_WAP))
	{
		header("location: index.php?_m=tickets&_a=list");
	}
}
?>